package com.example.other.netty.endecode;

import io.netty.channel.Channel;
import io.netty.util.Attribute;

/**
 * 为client的channel添加属性，如果登录成功，则将login设置为true
 */
public class LoginUtil {
    public static void markAsLogin(Channel channel){
        channel.attr(Attributes.LOGIN).set(true);
    }

    public static boolean hasLogin(Channel channel){
        Attribute<Boolean> loginAttr = channel.attr(Attributes.LOGIN);

        return loginAttr.get() != null;
    }
}
